package com.tesis_2.BL;

import java.util.ArrayList;

import org.json.JSONException;

import com.tesis_2.DA.DAORestaurants;
import com.tesis_2.DA.DAOUtils;
import com.tesis_2.MO.MORestaurant;

public class BLRestaurants {
	
	private static ArrayList<MORestaurant> lsRest;

	public static ArrayList<MORestaurant> getLsRest() {
		return lsRest;
	}

	public static void setLsRest(ArrayList<MORestaurant> lsRest) {
		BLRestaurants.lsRest = lsRest;
	}
	
	public static void fillRestaurants() throws JSONException{
		BLRestaurants.lsRest = DAORestaurants.getRestaurants();
		
	}
	
	public static MORestaurant createRest(MORestaurant Restaurant) throws JSONException
	{
		return DAORestaurants.createRest(Restaurant);
	}
	
	public static MORestaurant getRestById(Integer RestId) throws JSONException
	{
		ArrayList<MORestaurant> lsRestaurants = DAORestaurants.getRestaurantById(RestId);
		
		for (MORestaurant r:lsRestaurants)
		{
			if (r.getId()==RestId) return r;
		}
		
		
		return null;
	}

}
